﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TextBox
{
    public partial class TextBox: UserControl
    {
       
        public TextBox()
        {
            InitializeComponent();
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.UserPaint, true);
            Timer mytimer = new Timer();
            mytimer.Interval = 1000;
            mytimer.Tick += Mytimer_Tick;
            mytimer.Enabled = true;
        }

        private void Mytimer_Tick(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 数值
        /// </summary>
        private string actualValue = "0.0";
        public string ActualValue
        {
            get { return actualValue; }
            set { actualValue = value;
                this.lbl_data.Text = actualValue;
            }

        }

        /// <summary>
        /// 单位
        /// </summary>
        private string unit;
        public string Unit
        {
            get { return unit; }
            set
            {
                unit = value;
                this.lbl_unit.Text = unit;
            }

        }

        public delegate void BtnClickDelegate(object sender,EventArgs e);

        public event BtnClickDelegate UserControlClick;

        private void lbl_data_DoubleClick(object sender, EventArgs e)
        {
            if (UserControlClick != null)
            {
                UserControlClick(sender, new EventArgs());// 把按钮自身作为参数传递
            }
        }
    }
}
